package com.corpgovernment.common.dataloader;

import java.util.Objects;

import com.corpgovernment.common.feignRpc.CommonBasicClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.corpgovernment.common.base.JSONResult;
import com.ctrip.corp.obt.generic.utils.JsonUtils;

import lombok.extern.slf4j.Slf4j;

@Slf4j
@Service("commonBasicDataloader")
public class CommonBasicDataloader {

    @Autowired
    private CommonBasicClient commonBasicClient;

    public String getSupplierTicket(String supplierCorpId, String supplierCode, boolean useCache){
        JSONResult<String> data = commonBasicClient.ctripTokenByCorpID(supplierCorpId, supplierCode, useCache);
        if (Objects.isNull(data) || !data.isSUCCESS()){
            log.info("getSupplierTicket error:{}", JsonUtils.toJsonString(data));
            return null;
        }
        return data.getData();
    }

}
